/*//////////////////////////////////////////////////////////
 /// The methods defined in this  file is created by   /////
 /// prototype framework team. I choose some of them   /////
 /// for demo usage                                    /////
 /// @author - prototype team                          /////
 //////////////////////////////////////////////////////////*/

/**
 **	Array iterator
 **/
var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}

/**
 ** Standard class declaration 
 **/
var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

/**
 ** Standard class inherit 
 **/
Class.extend = function(destination, source) {
  for (property in source) {
    if(property.toString().indexOf("super_")!=-1) continue;
    if(destination[property]!=null) {
      destination["super_"+property] = source[property];
      continue;
    }else{
      destination[property] = source[property];
    }
  }
  return destination;
}

/**
 ** Bind scope 
 **/
Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}

/**
 ** Bind scope with event argument
 **/
Function.prototype.bindAsEventListener = function() {
    var __method = this, args = $A(arguments), object = args.shift();
    return function(event) {
      return __method.apply(object, [event || window.event].concat(args));
    }
}

